<template>
  <div>
    <svg-icon v-if="isFull" class="myicon" icon-class="exit-fullscreen" @click="toggle" />
    <svg-icon v-else class="myicon" icon-class="fullscreen" @click="toggle" />
  </div>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  name: 'ScreenFull',
  data() {
    return {
      isFull: false // 标识目前的屏幕状态 默认不全屏
    }
  },
  methods: {
    toggle() {
      if (ScreenFull.isEnabled) {
        ScreenFull.toggle()
        this.isFull = !this.isFull
      } else {
        this.$message.error('哥们, 该更新浏览器了..')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.myicon {
  width:20px;
  height:20px;
  fill: white;
  cursor: pointer;
}
</style>
